var data_zh = ['你知道吗', '六月', '一日', '星期一', '是', '儿童节','你好'];
var data_en = ['do you know', 'June', 'One day', 'Monday', 'Yes', 'Children\'s day','Holle'];
//中英互译
    function  zhToEn(){
        var text1 = document.querySelector("#text1").value;
        for(var i = 0;i < data_zh.length; i++){
            if(text1 == data_zh[i]){
                document.querySelector('#text2').value = data_en[i];
            }else if (text1 == data_en[i]){
                document.querySelector('#text2').value = data_zh[i];
            }
        }
    }
//中英按钮互换
    var zh = true;
    function switchLan(){
        var chin = document.querySelectorAll(".An .left span");
        var chin1 = document.querySelectorAll(".An .right span");
        if(zh){
            chin[0].classList.remove("aryn");
            chin[1].classList.add('aryn');
            chin1[0].classList.remove("aryn");
            chin1[1].classList.add("aryn");
        }else{
            chin[0].classList.add("aryn");
            chin[1].classList.remove('aryn');
            chin1[0].classList.add("aryn");
            chin1[1].classList.remove('aryn');
        }
        zh =! zh;
    }
//文本框输入汉字按钮在中文   文本框输入英文按钮在英文
    function tos(){
        var text1 = document.querySelector("#text1").value;
        var chin = document.querySelectorAll(".An .left span");
        var chin1 = document.querySelectorAll(".An .right span");
        for (var j = 1; j < data_en.length; j++){
            if(text1 == data_en[j]){
                chin[0].classList.remove("aryn");
                chin[1].classList.add('aryn');
                chin1[0].classList.remove("aryn");
                chin1[1].classList.add("aryn");

            }else if(text1 == data_zh[j]){
                chin[0].classList.add("aryn");
                chin[1].classList.remove('aryn');
                chin1[0].classList.add("aryn");
                chin1[1].classList.remove('aryn');
            }
        }
        
        
        if(text1 !== data_zh[0] && text1 !== data_zh[1] && text1 !== data_zh[2]
        && text1 !== data_zh[3] && text1 !== data_zh[4] && text1 !== data_zh[5] 
        && text1 !== data_zh[6] && text1 !== data_en[0] && text1 !== data_en[1] 
        && text1 !== data_en[2] && text1 !== data_en[3] && text1 !== data_en[4]
        && text1 !== data_en[5] && text1 !== data_en[6]){
            alert("无法翻译");
        }
    }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            